/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DAL;
import java.sql.*;
/**
 *
 * @author patricio
 */
public class Conectarse {

    Connection conn;

   public Conectarse(){
        verificar();
        conectarse();
    }

    public String verificar(){
            try
            {
              Class.forName("com.mysql.jdbc.Driver");
              return "exito";

            }
            catch(ClassNotFoundException e)
            {
                System.out.println("Falta el conector");
                return "falta el connector";
            }

        }

    public String conectarse (){
        try
        {
            conn = DriverManager.getConnection("jdbc:mysql://urps.us/kenin_tdp_final","kenin_usuario","p4ssw0rd");
            //conn = DriverManager.getConnection("jdbc:mysql"+db,"root","");
            return "exito";
        }
        catch(SQLException e)
        {
            System.out.println("No conectado");
            return "servidor no conectado";
        }
    }

    public Statement crearSentencia()
    {

        try
        {
            return conn.createStatement();
        }
        catch(SQLException e)
        {
            return null;
         }
    }

}



